package com.xye.auth.base.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

/**
 * generated by Generate POJOs.groovy
 *
 * LoginUser:登录用户通用信息封装 全部来源于有效的移动内部用户和有效的供应商外部用户
 * @author yag
 * @create: 2019-03-11 14:30:56
 * @version 1.0.0
 */

@ApiModel(value="LoginUser:登录用户通用信息封装")
@Data
@TableName("SCMV_LOGIN_USER")
public class LoginUser implements UserDetails, Serializable {
  /** serialVersionUID*/
  private static final long serialVersionUID = 4804158763636118389L;


  @ApiModelProperty(value = " 用户序列ID 来源于UUID", dataType="String")
  @TableId
  private String userId;

  @ApiModelProperty(value = " 用户类型 mobile 移动客户 vendor 供应商用户", dataType="String")
  private String userType;


  @ApiModelProperty(value = " 登录用户名 存在惟一性", dataType="String")
  private String loginName;

  @ApiModelProperty(value = " 用户 登录密码 默认存在加密", dataType="String")
  private String password;

  @ApiModelProperty(value = " 用户名称 ", dataType="String")
  private String userRealName;

  @ApiModelProperty(value = " 用户手机号 ", dataType="String")
  private String phone;

  @ApiModelProperty(value = " 单位序列ID 来源于 SCMC_ORGANIZATION.ORGANIZATION_ID  userType=mobile时用", dataType="String")
  private String unitId;

  @ApiModelProperty(value = " 单位名称 来源于 SCMC_ORGANIZATION.ORGANIZATION_NAME  userType=mobile时用", dataType="String")
  private String unitName;

  @ApiModelProperty(value = " 部门序列ID 来源于 SCMC_ORGANIZATION.ORGANIZATION_ID  userType=mobile时用", dataType="String")
  private String deptId;

  @ApiModelProperty(value = " 部门名称 来源于 SCMC_ORGANIZATION.ORGANIZATION_NAME  userType=mobile时用", dataType="String")
  private String deptName;

  @ApiModelProperty(value = " 科室序列ID 来源于 SCMC_ORGANIZATION.ORGANIZATION_ID  userType=mobile时用", dataType="String")
  private String officeId;

  @ApiModelProperty(value = " 科室名称 来源于 SCMC_ORGANIZATION.ORGANIZATION_NAME  userType=mobile时用", dataType="String")
  private String officeName;

  @ApiModelProperty(value = " 供应商ID 来源于 SCMC_VENDOR.VENDOR_ID  userType=vendor 时用", dataType="String")
  private String vendorId;

  @ApiModelProperty(value = " 供应商名称 来源于 SCMC_VENDOR.VENDOR_NAME  userType=vendor 时用", dataType="String")
  private String vendorName;

  @ApiModelProperty(value = "部门类型 unit 单位 dept 部门  county 区县 office 科室  userType=mobile时用", dataType="String")
  private String deptType;

  @ApiModelProperty(value = " 是否启用 1 启用 0 禁用", dataType="Long")
  private Long activeFlag;

  @ApiModelProperty(value = " 是否锁住 1 是 0 否", dataType="Long")
  private Long lockFlag;



  @Override
  public Collection<GrantedAuthority> getAuthorities() {
    Collection<GrantedAuthority> collection = new HashSet<>();
   /* if (!CollectionUtils.isEmpty(roleBeans)) {
      roleBeans.forEach(role -> {
        collection.add(new SimpleGrantedAuthority(role.getRoleCode()));
      });
    }*/

    return collection;
  }

  @Override
  public String getPassword() {
    return password;
  }

  @Override
  public String getUsername() {
    return loginName+"@"+userType;
  }



  @Override
  public boolean isAccountNonExpired() {
    return true;
  }

  @Override
  public boolean isAccountNonLocked() {
    return true;
  }

  @Override
  public boolean isCredentialsNonExpired() {
    return true;
  }

  @Override
  public boolean isEnabled() {
    return true;
  }

  public static long getSerialVersionUID() {
    return serialVersionUID;
  }

  public String getUserId() {
    return userId;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  public String getUserType() {
    return userType;
  }

  public void setUserType(String userType) {
    this.userType = userType;
  }

  public String getLoginName() {
    return loginName;
  }

  public void setLoginName(String loginName) {
    this.loginName = loginName;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public String getUserRealName() {
    return userRealName;
  }

  public void setUserRealName(String userRealName) {
    this.userRealName = userRealName;
  }

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getUnitId() {
    return unitId;
  }

  public void setUnitId(String unitId) {
    this.unitId = unitId;
  }

  public String getUnitName() {
    return unitName;
  }

  public void setUnitName(String unitName) {
    this.unitName = unitName;
  }

  public String getDeptId() {
    return deptId;
  }

  public void setDeptId(String deptId) {
    this.deptId = deptId;
  }

  public String getDeptName() {
    return deptName;
  }

  public void setDeptName(String deptName) {
    this.deptName = deptName;
  }

  public String getOfficeId() {
    return officeId;
  }

  public void setOfficeId(String officeId) {
    this.officeId = officeId;
  }

  public String getOfficeName() {
    return officeName;
  }

  public void setOfficeName(String officeName) {
    this.officeName = officeName;
  }

  public String getVendorId() {
    return vendorId;
  }

  public void setVendorId(String vendorId) {
    this.vendorId = vendorId;
  }

  public String getVendorName() {
    return vendorName;
  }

  public void setVendorName(String vendorName) {
    this.vendorName = vendorName;
  }

  public String getDeptType() {
    return deptType;
  }

  public void setDeptType(String deptType) {
    this.deptType = deptType;
  }

  public Long getActiveFlag() {
    return activeFlag;
  }

  public void setActiveFlag(Long activeFlag) {
    this.activeFlag = activeFlag;
  }

  public Long getLockFlag() {
    return lockFlag;
  }

  public void setLockFlag(Long lockFlag) {
    this.lockFlag = lockFlag;
  }



  @Override
  public String toString() {
    return "LoginUser{" +
            "userId='" + userId + '\'' +
            ", userType='" + userType + '\'' +
            ", loginName='" + loginName + '\'' +
            ", password='" + password + '\'' +
            ", userRealName='" + userRealName + '\'' +
            ", phone='" + phone + '\'' +
            ", unitId='" + unitId + '\'' +
            ", unitName='" + unitName + '\'' +
            ", deptId='" + deptId + '\'' +
            ", deptName='" + deptName + '\'' +
            ", officeId='" + officeId + '\'' +
            ", officeName='" + officeName + '\'' +
            ", vendorId='" + vendorId + '\'' +
            ", vendorName='" + vendorName + '\'' +
            ", deptType='" + deptType + '\'' +
            ", activeFlag=" + activeFlag +
            ", lockFlag=" + lockFlag +
            '}';
  }
}
